package win.smartown.library.easyAdapter;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


/**
 * Author:Tiger
 * <p>
 * CrateTime:2017/2/22 14:32
 * <p>
 * Description:
 */
public abstract class EasyAdapter extends RecyclerView.Adapter<EasyViewHolder> {

    private Context mContext;

    public EasyAdapter(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public EasyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new EasyViewHolder(getItemView(parent, viewType));
    }

    public View getItemView(ViewGroup parent, int viewType) {
        return LayoutInflater.from(mContext).inflate(getItemLayout(viewType), parent, false);
    }

    @LayoutRes
    public int getItemLayout(int viewType) {
        return android.R.layout.activity_list_item;
    }

    public Context getContext() {
        return mContext;
    }
}
